<%@page contentType="text/html" import="java.util.Collection, Bean.*"%>
<%@page pageEncoding="UTF-8"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%
if(session.getAttribute("un")==null){
    response.sendRedirect("indexAdmin.jsp?page=Admin&url=Login");
    out.println("You must be login..!");
}else{%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
</head>
<body>
<form action="SearchStudent" name="formstudent" id="formstudent" method="get" >
    <h3 align="center">Search Student</h3>
    <table>
        <tr>
            <td>Rollno: </td>
            <td><input type="text" name="txtsearch" value="" /></td>
            <td><input type="submit" name="bt" value="Search"  /> <a href="indexAdmin.jsp?page=Admin&url=Student">Back..!</a></td>
        </tr>
    </table>
    <br>
    
    <c:if test="${not empty search}">
        <table border="1">
        <tr>
            <th>Rollno</th>
            <th>Student Name</th>
            <th>Gender</th>
            <th>Address</th>
            <th>Phone</th>
            <th>Email</th>
            <th colspan="2">Action</th>
        </tr>
        <c:forEach items="${search}" var="s">
            <tr>
                <td><c:out value="${s.rollno}" /></td>
                <td>${s.stname}</td>
                <td>${s.gender}</td>
                <td>${s.address}</td>
                <td>${s.phone}</td>
                <td>${s.email}</td>
                <c:url var="delete" value="SearchStudent">
                    <c:param name="bt" value="Delete" />
                    <c:param name="rollno" value="${s.rollno}" />
                    <c:param name="txtSearch" value="${param.txtsearch}"/>
                </c:url>
                <c:url var="edit" value="SearchStudent">
                    <c:param name="bt" value="Edit" />
                    <c:param name="rollno" value="${s.rollno}" />
                    
                    <c:param name="stname" value="${s.stname}" />
                    <c:param name="gender" value="${s.gender}" />
                    <c:param name="address" value="${s.address}" />
                    <c:param name="phone" value="${s.phone}" />
                    <c:param name="email" value="${s.email}" />
                </c:url>
                <% if(session.getAttribute("permission")!=null){
                    if(session.getAttribute("permission").equals("Academic")){%>
                <td><a href="${edit}">Edit</a></td>
                <%    
                    }
                %>
                <% 
                if(session.getAttribute("permission").equals("Admin")){%>
                <td><a href="${edit}">Edit</a></td>
                <td><a href="${delete}" onclick="return confirm('Do you really want to delete these records ?')">Delete</a></td>
                <%    
                }
                %>
                <%}%>
            </tr>
        </c:forEach>
    </c:if>
    </table>
</form>
</body>
</html>
<%}%>